from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import sessionmaker
from src.config import db_config

user = db_config['pg']['user']
password = db_config['pg']['password']
host = db_config['pg']['host']
dbname = db_config['pg']['dbname']
port = db_config['pg']['port']

db_url_pg = f"postgresql://{user}:{password}@{host}:{port}/{dbname}"
engine_pg = create_engine(db_url_pg)

# session maker 配置数据库会话类，设置手动提交和刷新
SessionPgTest = sessionmaker(autocommit=False, autoflush=False, bind=engine_pg)
db = SessionPgTest()
Base = declarative_base()
